﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ServiceProcess;

namespace SeverTest
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void button_Click(object sender, RoutedEventArgs e)
        {
            string CurrentDirectory = System.Environment.CurrentDirectory;
            System.Environment.CurrentDirectory = CurrentDirectory + "\\server";
            Process process = new Process
            {
                StartInfo =
                {
                    UseShellExecute = false,
                    FileName = "Install.bat",
                    CreateNoWindow = true
                }
            };
            process.Start();
            System.Environment.CurrentDirectory = CurrentDirectory;
        }


        private void button_Copy_Click(object sender, RoutedEventArgs e)
        {
            ServiceController serviceController = new ServiceController("LRomateSever");
            switch (serviceController.Status)
            {
                case ServiceControllerStatus.ContinuePending:
                    break;
                case ServiceControllerStatus.Paused:
                    serviceController.Continue();
                    break;
                case ServiceControllerStatus.PausePending:
                    break;
                case ServiceControllerStatus.Running:
                    break;
                case ServiceControllerStatus.StartPending:
                    break;
                case ServiceControllerStatus.Stopped:
                    serviceController.Start();
                    break;
                case ServiceControllerStatus.StopPending:
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
            string Status = serviceController.Status.ToString();
            Trace.WriteLine(Status);
           
        }
    }
}
